package com.cn.ycy;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.core.PriorityOrdered;
import org.springframework.stereotype.Component;

/**
 * 一辈子只在加载bean 之后调用（注意不是实例化），只调用一次
 */
@Component
public class BeanFactoryPostProcessorDemo implements BeanFactoryPostProcessor, PriorityOrdered {

  @Override
  public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
    System.out.println("容器启动只调用一次, BeanFactoryPostProcessorDemo：" + beanFactory);
  }

  @Override
  public int getOrder() {
    return 0;
  }
}
